package pl.perseus.action;

import lombok.Getter;
import lombok.Setter;

import org.springframework.beans.factory.annotation.Autowired;

import pl.perseus.model.Degree;
import pl.perseus.service.degree.IDegreeService;

public class UpdateStudentDegreeAction extends BaseAction {

	@Autowired
	IDegreeService degreeService;
	
	@Getter
	@Setter
	Degree degree;
	
	@Getter
	@Setter
	String degreevalue;
	
	@Override
	public String execute() {
		
		Degree obtained = degreeService.selectByIdDegree(degree.getId());
		
		degree.setId_classes(obtained.getId_classes());
		degree.setId_student(obtained.getId_student());
		degree.setDegreevalue(Double.parseDouble(degreevalue));
		degree.setActive(true);
		
		degreeService.updateDegree(degree);
		logAction("Editing student grade: " + degree.getDegreename() +" " +degreevalue);
		return SUCCESS;
	}

}
